/**
 * <copyright>
 * </copyright>
 *

 */
package org.openarchitectureware.recipe2.dsl.detector.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.openarchitectureware.recipe2.dsl.detector.Detector;
import org.openarchitectureware.recipe2.dsl.detector.DetectorPackage;
import org.openarchitectureware.recipe2.dsl.detector.Parameter;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Detector</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.openarchitectureware.recipe2.dsl.detector.impl.DetectorImpl#getPredef <em>Predef</em>}</li>
 *   <li>{@link org.openarchitectureware.recipe2.dsl.detector.impl.DetectorImpl#getMessage <em>Message</em>}</li>
 *   <li>{@link org.openarchitectureware.recipe2.dsl.detector.impl.DetectorImpl#getParameters <em>Parameters</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DetectorImpl extends MinimalEObjectImpl.Container implements Detector
{
  /**
   * The default value of the '{@link #getPredef() <em>Predef</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPredef()
   * @generated
   * @ordered
   */
  protected static final String PREDEF_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPredef() <em>Predef</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPredef()
   * @generated
   * @ordered
   */
  protected String predef = PREDEF_EDEFAULT;

  /**
   * The default value of the '{@link #getMessage() <em>Message</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMessage()
   * @generated
   * @ordered
   */
  protected static final String MESSAGE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMessage() <em>Message</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMessage()
   * @generated
   * @ordered
   */
  protected String message = MESSAGE_EDEFAULT;

  /**
   * The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParameters()
   * @generated
   * @ordered
   */
  protected EList<Parameter> parameters;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DetectorImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return DetectorPackage.Literals.DETECTOR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPredef()
  {
    return predef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPredef(String newPredef)
  {
    String oldPredef = predef;
    predef = newPredef;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DetectorPackage.DETECTOR__PREDEF, oldPredef, predef));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMessage()
  {
    return message;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMessage(String newMessage)
  {
    String oldMessage = message;
    message = newMessage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DetectorPackage.DETECTOR__MESSAGE, oldMessage, message));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Parameter> getParameters()
  {
    if (parameters == null)
    {
      parameters = new EObjectContainmentEList<Parameter>(Parameter.class, this, DetectorPackage.DETECTOR__PARAMETERS);
    }
    return parameters;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case DetectorPackage.DETECTOR__PARAMETERS:
        return ((InternalEList<?>)getParameters()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case DetectorPackage.DETECTOR__PREDEF:
        return getPredef();
      case DetectorPackage.DETECTOR__MESSAGE:
        return getMessage();
      case DetectorPackage.DETECTOR__PARAMETERS:
        return getParameters();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case DetectorPackage.DETECTOR__PREDEF:
        setPredef((String)newValue);
        return;
      case DetectorPackage.DETECTOR__MESSAGE:
        setMessage((String)newValue);
        return;
      case DetectorPackage.DETECTOR__PARAMETERS:
        getParameters().clear();
        getParameters().addAll((Collection<? extends Parameter>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case DetectorPackage.DETECTOR__PREDEF:
        setPredef(PREDEF_EDEFAULT);
        return;
      case DetectorPackage.DETECTOR__MESSAGE:
        setMessage(MESSAGE_EDEFAULT);
        return;
      case DetectorPackage.DETECTOR__PARAMETERS:
        getParameters().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case DetectorPackage.DETECTOR__PREDEF:
        return PREDEF_EDEFAULT == null ? predef != null : !PREDEF_EDEFAULT.equals(predef);
      case DetectorPackage.DETECTOR__MESSAGE:
        return MESSAGE_EDEFAULT == null ? message != null : !MESSAGE_EDEFAULT.equals(message);
      case DetectorPackage.DETECTOR__PARAMETERS:
        return parameters != null && !parameters.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (predef: ");
    result.append(predef);
    result.append(", message: ");
    result.append(message);
    result.append(')');
    return result.toString();
  }

} //DetectorImpl
